Return feedback instead of crashing on submissions with no notes - #19
Open
peterbjohnson wants to merge 1 commit into
Open
Return feedback instead of crashing on submissions with no notes#19peterbjohnson wants to merge 1 commit into
peterbjohnson wants to merge 1 commit into
Conversation
An empty note list raised IndexError, which reached the student as a 500 rather than a feedback message. This is reachable in production: a student submits nothing, uploads a silent or failed recording, or plays so quietly that transcription returns no notes. Three changes: - event_alignment_ED indexed element zero to decide whether its input was already grouped into events. Skip that check when the list is empty; the cost matrix boundary conditions already handle a zero-length side. - build_cost_matrix built its arrays without explicit dtypes, so an empty list produced float arrays and the boolean chord mask raised TypeError. Give the dtypes explicitly. - Report the degenerate cases plainly. Describing every reference note as "missed" is misleading when nothing was submitted, and an empty response against an empty reference must not be marked correct. Tests go in evaluation_test.py as section 11, alongside the other tests for compare_performance_ED and evaluation_function. Short submissions of one or two notes already worked and are covered so they stay working. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
peterbjohnson
force-pushed
the
empty_input_guard
branch
from
September 9, 2026 20:38
a8343d8 to
4fd1e1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13
Problem
An empty note list raised
IndexError, which reaches the student as a 500 rather than a feedback message.This is reachable in production: a student submits nothing, uploads a silent or failed recording, or plays so quietly that transcription returns no notes at all.
Approach
Tests first, added to
evaluation_test.pyas section 11, alongside the existing tests forcompare_performance_ED(section 7) andevaluation_function(section 8). Before the change:The four passes are the deliberate control: one- and two-note submissions already worked, and they are covered so they stay working. All three empty combinations crashed.
What was actually broken
Two distinct faults, the second only visible once the first was fixed.
1. Indexing element zero of an empty list.
event_alignment_EDinspectedresponse_events[0]to decide whether its input was already grouped into events. The edit-distance boundary conditions already handle a zero-length side correctly, so the check just needed to be skipped when the list is empty.2. Float arrays from empty lists. With the first fault fixed,
build_cost_matrixfailed differently:np.array([])defaults tofloat64, so the chord flags came back as floats and the&mask raised. The dtypes are now given explicitly.Reporting the degenerate cases
Structurally the pipeline now produces the right numbers: an empty response marks all four reference notes missing. But the standard wording would be misleading, so both degenerate cases get their own message.
Empty response:
Empty reference (a misconfigured question, not a student error):
is_correctis now also guarded, because an empty response against an empty reference satisfied every count and was being reported as correct.Verification
🤖 Generated with Claude Code